package com.eshin.demo;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.client.RestClientBuilderConfigurer;
import org.springframework.boot.web.client.ClientHttpRequestFactories;
import org.springframework.boot.web.client.ClientHttpRequestFactorySettings;
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.web.client.RestClient;
import org.springframework.web.reactive.function.client.WebClient;

import java.util.Map;

/**
 * @author Eshin
 * @title: configuration
 * @projectName assistant_framework
 * @date 2024/9/2613:12
 */
@Configuration
public class TestConfiguration {
    @Value("${header.secrect}")
    String secret;
    @Bean
    @Scope("prototype")
    public WebClient.Builder webClientBuilder(ObjectProvider<WebClientCustomizer> customizerProvider) {
        WebClient.Builder builder = WebClient.builder();
        customizerProvider.orderedStream().forEach((customizer) -> {
            customizer.customize(builder);
        });
        builder.defaultHeader("X-Server-Param",secret);
        return builder;
    }
    @Bean
    @Scope("prototype")
    RestClient.Builder restClientBuilder(RestClientBuilderConfigurer restClientBuilderConfigurer) {
        RestClient.Builder builder = RestClient.builder().requestFactory(ClientHttpRequestFactories.get(ClientHttpRequestFactorySettings.DEFAULTS));
        builder.defaultHeader("X-Server-Param",secret);
        return restClientBuilderConfigurer.configure(builder);
    }

//    @Bean(value = "transformersEmbeddingModel")
//    public TransformersEmbeddingModel embeddingModel(TransformersEmbeddingModelProperties properties) {
//
//        TransformersEmbeddingModel embeddingModel = new TransformersEmbeddingModel(properties.getMetadataMode());
//
//        embeddingModel.setDisableCaching(!properties.getCache().isEnabled());
//        embeddingModel.setResourceCacheDirectory(properties.getCache().getDirectory());
//
//        embeddingModel.setTokenizerResource(properties.getTokenizer().getUri());
//        embeddingModel.setTokenizerOptions(properties.getTokenizer().getOptions());
//
//        embeddingModel.setModelResource(properties.getOnnx().getModelUri());
//
//        embeddingModel.setGpuDeviceId(properties.getOnnx().getGpuDeviceId());
//
//        embeddingModel.setModelOutputName(properties.getOnnx().getModelOutputName());
//
//        return embeddingModel;
//    }
}
